package cn.yitun.chat.yitunserverimbase.dao.userchat;

import cn.yitun.chat.yitunservercommonlib.crud.yitun.CrudDao;
import cn.yitun.chat.yitunservercommonlib.dataentity.data.base.chat.UserChatHistoryDto;
import cn.yitun.chat.yitunservercommonlib.dataentity.data.base.chat.UserOfflineCount;
import cn.yitun.chat.yitunservercommonlib.dataentity.dto.userchat.UserChatContentDto;
import cn.yitun.chat.yitunservercommonlib.dataentity.po.userchat.UserChatContentInfo;
import cn.yitun.chat.yitunservercommonlib.dataentity.vo.userchat.UserChatContentVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 用户聊天内容表
 * @author chenyitun
 * @email chenyitun@163.com
 * @date 2020-05-27 14:44:44
 */
@Mapper
public interface UserChatContentDao extends CrudDao<UserChatContentDto, UserChatContentInfo, UserChatContentVo> {

	int absDel(Long id);

	int batchAbsDel(Long[] ids);

	/**
	 * 获取聊天内容
	 * @param chatReceiveUserId
	 * @param chatSendUserId
	 * @param messageId
	 * @return
	 */
	UserChatContentVo getUserChatContentByMessageId(@Param("chatReceiveUserId") Long chatReceiveUserId,
													@Param("chatSendUserId") Long chatSendUserId,
													@Param("messageId") Long messageId);

	/**
	 * 获取聊天内容
	 * @param chatReceiveUserId
	 * @param chatSendUserId
	 * @param outId
	 * @param outMessageId
	 * @param latest
	 * @return
	 */
	List<UserChatContentVo> getUserChatContentList(@Param("chatReceiveUserId") Long chatReceiveUserId,
												   @Param("chatSendUserId") Long chatSendUserId,
												   @Param("outId") Long outId,
												   @Param("outMessageId") Long outMessageId,
												   @Param("latest") boolean latest,
												   @Param("timestamp") Long timeStamp,
												   @Param("searchNum") Integer searchNum);

	/**
	 * 获取聊天内容
	 * @param idList
	 * @return
	 */
	List<UserChatContentVo> getListByIdList(@Param("list") List<Long> idList);

	int updateToRead(@Param("receiveUserId") Long receiveUserId,
					 @Param("sendUserId") Long sendUserId,
					 @Param("id") Long contentId,
					 @Param("messageId") Long messageId);

	/**
	 * 获取发送离线信息的用户id
	 * @param receiveUserId
	 * @return
	 */
	List<Long> getOfflineUserIdList(@Param("receiveUserId") Long receiveUserId);

	/**
	 * 获取离线消息数量
	 * @param receiveUserId
	 * @return
	 */
	List<UserOfflineCount> getOfflineCountList(@Param("receiveUserId") Long receiveUserId);

	/**
	 * 获取指定相送离线消息的数量
	 * @param receiveUserId
	 * @param ids
	 * @return
	 */
	List<Map<String, Object>> getOfflineCountListByIds(@Param("receiveUserId") Long receiveUserId,
													   @Param("ids") List<Long> ids);

	/**
	 * 获取用户聊天记录
	 * @param query
	 * @return
	 */
    List<UserChatContentVo> queryUserChatContentList(UserChatHistoryDto query);

	/**
	 * 获取特定区域内人员发送的离线消息
	 * @param receiveUserId
	 * @param sendUserIds
	 * @return
	 */
	List<UserOfflineCount> getOfflineCountListBySendUserIds(@Param("receiveUserId") Long receiveUserId, @Param("sendUserIds") List<Long> sendUserIds);
}
